<?php 
class communityModel extends CDBModelBase {
	public function getTabelName(){
		return "t_community";
	}

	public function getPKID(){
		return "community_id";
	}
	
	protected function getSequence()
	{
		return "COMMUNITY_SEQUENCE";
	}

	/**
	 * 根据区域获取社区信息
	 * @param string $province
	 * @param string $city
	 * @param string $area
	 */
	public function getCommunityByArea($province,$city,$area)
	{
		$where = "province =:province";
		$param = array(array(":province", $province, PDO::PARAM_STR));
		if($city)
		{
			$param[] = array(":city", $city, PDO::PARAM_STR);
			$where .= " and city=:city";
		}

		if($area)
		{
			$param[] = array(":area", $area, PDO::PARAM_STR);
			$where .= " and area=:area";
		}
		$sql ='select community_id,community_name from T_COMMUNITY 
				where '.$where.' and del_flag=0';
		return $this->db->executeDataSet($sql, $param);
	}
	
	/**
	 * 根据社区名称查询社区ID列表
	 * @param unknown_type $name
	 */
	public function getNameByID($name)
	{
		$param = array(array(":community_name", $name, PDO::PARAM_STR));
		
		$sql ='select community_id from T_COMMUNITY
				where community_name=:community_name and del_flag=0';
		return $this->db->executeDataSet($sql, $param);
	}
}
?>
